import Vue from 'vue'
import VueResource from 'vue-resource'
import {
  API_ROOT,
  CDC_API_ROOT
}
from '../config'


Vue.use(VueResource)

// HTTP相关
// Vue.http.options.crossOrigin = true
// Vue.http.options.xhr = {
//     withCredentials: true
//   }
//
// Vue.http.interceptors.push({
//   request(request) {
//       // 这里对请求体进行处理
//       request.headers = request.headers || {}
//       if (getCookie('token')) {
//         request.headers.Authorization = 'Bearer ' + getCookie('token').replace(
//           /(^\")|(\"$)/g, '')
//       }
//       return request
//     },
//     response(response) {
//       // 这里可以对响应的结果进行处理
//       if (response.status === 401) {
//         signOut()
//         window.location.pathname = '/login'
//       }
//       return response
//     }
// })

export const OrderResource = Vue.resource(
    '/api/cdc/order/ordering')
  // export const AuthResource = Vue.resource(API_ROOT + 'auth{/id}')
export const OrderPayWechatResource = Vue.resource(
  '/api/cdc/order/pay/wechat')

export const OPenidResource = Vue.resource(
  '/api/cdc/wechat/openid'
)

export const checkoutOfFastOrderResource = Vue.resource(
  '/api/cdc/order/checkoutOfFastOrder')

export const getOrderListResource = Vue.resource(
  '/api/cdc/order/getOrderList')



export const orderResource = Vue.resource(
  '/api/cdc/order{/id}{/controller}')

export const storesResource = Vue.resource(
  '/api/cdc/stores{/id}{/controller}')
